package com.videri.match.client;

import java.io.Serializable;

import com.google.gwt.user.client.rpc.IsSerializable;

public class Rectangle implements IsSerializable, Serializable {
	/**
	 * 
	 */
	private static final long serialVersionUID = -1970953093950385195L;
	public int x,y,w,h;
	
	public Rectangle()
	{
		x=y=w=h=0;
	}
	
	public Rectangle(int startx, int starty, int mousex, int mousey) {
		if (mousex > startx) {
			x = startx;
			w = mousex - startx;
		}
		else {
			x = mousex;
			w = startx - mousex;
		}
		if (mousey > starty) {
			y = starty;
			h = mousey - starty;
		}
		else {
			y = mousey;
			h = starty - mousey;
		}
	}
	
	public boolean isInside(int x2, int y2)
	{
		return (x2 >= x && x2 <= (x+w) && y2 >= y && y2 <= (y+h));
	}
	
	public boolean equals(Object other) {
		Rectangle a = (Rectangle)other;
		return (x==a.x && y==a.y && h==a.h && w==a.w);
	}
}
